#include "stdio.h"
#include "string.h"

//结构体的定义与使用
//C结构体想当与java中的类

struct Dog {
    //成员变量
    char name[20];
    int age;
    char sex;
};

struct Person {
    char name[20];
    int age;
    char sex;
} person = {"小明", 18, 'm'},
        person1 = {"小王", 18, 'w'};

int main() {
    struct Dog dog;//这样写完：成员是没有任何初始值的，默认值是系统值
    printf("000name=%s,age:%d,sex:%c\n", dog.name, dog.age, dog.sex);
    //赋值操作---第一种写法
    strcpy(dog.name, "旺财");
    dog.age = 5;
    dog.sex = 'm';
    printf("1111name=%s,age:%d,sex:%c\n ", dog.name, dog.age, dog.sex);

    //赋值操作---第二种写法
    printf("person-----name=%s,age:%d,sex:%c\n", person.name, person.age, person.sex);

    //结构体指针   ->调用一级指针成员！！！！
    struct Person *p = &person;
    strcpy(p->name, "小红");
    p->age = 88;
    printf("p-----name=%s,age:%d,sex:%c", p->name, p->age, p->sex);
    return 0;
}